//
//  XLZ_MainViewController.m
//  XLZChat
//
//  Created by 徐昊 on 2016/10/18.
//  Copyright © 2016年 徐昊. All rights reserved.
//

#import "XLZ_MainViewController.h"

@interface XLZ_MainViewController ()

@end

@implementation XLZ_MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    NSArray *array = @[
                       @{@"className": @"XLZ_MessageViewController", @"tabbarTitle": @"消息", @"tabbarImageName": @""},
                       @{@"className": @"XLZ_ContactViewController", @"tabbarTitle": @"联系人", @"tabbarImageName": @""},
                       @{@"className": @"XLZ_CircleOfFriendsViewController", @"tabbarTitle": @"动态", @"tabbarImageName": @""}];
    
    self.viewControllers = [self creatVCArray:array];
    
}

- (__kindof UIViewController *)creatVCWithClassName:(NSString *)className tabbarTitle:(NSString *)tabbarTitle tabberImageName:(NSString *)tabbarImageName {
    Class vcClass = NSClassFromString(className);
    UIViewController *vc = [vcClass new];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
    nav.tabBarItem.title = tabbarTitle;
    nav.tabBarItem.image = [UIImage imageNamed:tabbarImageName];
    return nav;
}

- (NSArray<UIViewController *> *)creatVCArray:(NSArray *)vcConfihArray {
    NSMutableArray *array = [NSMutableArray array];
    for (NSDictionary *dic in vcConfihArray) {
        UIViewController *vc = [self creatVCWithClassName:dic[@"className"] tabbarTitle:dic[@"tabbarTitle"] tabberImageName:dic[@"tabbarImageName"]];
        [array addObject:vc];
    }
    return array;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
